<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	System.out.print(path);
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	System.out.print(basePath);
%>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TI - browserConfig</title>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
	function deleteConfigBrowser(o) {
		if (window.confirm("确认删除?"))
			window.location.href = "deleteConfigBrowser.action?id=" + o.id;
	}
	
	function statusCheck(){
		$.ajax({
			type : "POST",
			url : "statusCheck.action",
			data : "",
			async : false,
			cache : false,
			success : function(msg) {
				
				var statusE = $(".status");
				for (var int = 0; int < statusE.length; int++) {
					statusE.eq(int).empty();
					statusE.eq(int).append("<em class=\"glyphicon glyphicon-play\">运行中...</em>");
				}
				
				var idStr = msg.split(",");
				
				for (var int = 0; int < idStr.length; int++) {
					$("#status_"+idStr[int]).empty();
					/* <em class="glyphicon glyphicon-play">运行中...</em> */
					$("#status_"+idStr[int]).append("<em class=\"glyphicon glyphicon-stop\">停止</em>");
				}
				
			},
			error : function(e) {
				alert("对不起，后台处理发生异常，请联系管理员!");
			}
		});
	}
	
	$(document).ready(function() {
		$("#browserSubmit").click(function() {
			$("#browserForm").submit();
		});
		statusCheck();
		
		setInterval(statusCheck, 5000); 
		
	});
</script>
</head>
<body>
	<div class="row clearfix">
		<div class="col-md-12 column">
			<h4>
				<em class="glyphicon glyphicon-subtitles"></em>
				Browser-System-Version-相关配置
			</h4>
		</div>
	</div>
	<div class="row clearfix">
		<div class="col-md-12 column">
			<a id="modal-86913" href="#modal-container-86913" role="button"
				class="btn btn-primary" data-toggle="modal">配置Browser</a>

			<div class="modal fade" id="modal-container-86913" role="dialog"
				aria-labelledby="myModalLabel" aria-hidden="true"
				data-backdrop="static">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel">Browser配置增加</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" role="form" id="browserForm"
								action="saveConfigBrowser.action" methdo="POST">
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">浏览器名称</label>
									<div class="col-sm-3">
										<select class="form-control" name="browser.browserName">
											<option value="请选择">请选择</option>
											<option value="chrome">chrome</option>
											<option value="internet explorer">internet explorer</option>
											<option value="firefox">firefox</option>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">版本</label>
									<div class="col-sm-3">
										<input class="form-control" id="" type="text"
											name="browser.browserVersion" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">操作系统</label>
									<div class="col-sm-3">
										<select class="form-control" name="browser.systemName">
											<option value="请选择">请选择</option>
											<option value="WINDOWS">WINDOWS</option>
											<option value="WIN8">WIN8</option>
											<option value="WIN8_1">WIN8_1</option>
											<option value="MAC">MAC</option>
											<option value="LINUX">LINUX</option>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">IP</label>
									<div class="col-sm-8">
										<input class="form-control" id="" type="text"
											name="browser.ip" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputEmail3" class="col-sm-3 control-label">端口</label>
									<div class="col-sm-8">
										<input class="form-control" id="" type="text"
											name="browser.port" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">MAX线程</label>
									<div class="col-sm-8">
										<input class="form-control" id="" type="text"
											name="browser.maxSession" />
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-3 control-label">MAX-DRIVER实例</label>
									<div class="col-sm-8">
										<input class="form-control" id="" type="text"
											name="browser.maxInstance" />
									</div>
								</div>
						</div>
						<div class="modal-footer">
							<button type="reset" class="btn btn-default">重置</button>
							<button type="submit" class="btn btn-primary" id="browserSubmit"
								data-dismiss="modal">提交</button>
						</div>
						</form>
					</div>

				</div>

			</div>

			<table class="table table-hover table-condensed table-striped">
				<thead>
					<tr>
						<th>ID</th>
						<th>浏览器</th>
						<th>版本</th>
						<th>系统</th>
						<th>IP</th>
						<th>端口</th>
						<th>MAX线程</th>
						<th>MAX实例</th>
						<th>配置人</th>
						<th>配置时间</th>
						<th>状态Status</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="browsers" var="browser">
						<tr>
							<td>browser-<s:property value="#browser.id" /></td>
							<td><s:property value="#browser.browserName" /></td>
							<td><s:property value="#browser.browserVersion" /></td>
							<td><s:property value="#browser.systemName" /></td>
							<td><s:property value="#browser.ip" /></td>
							<td><s:property value="#browser.port" /></td>
							<td><s:property value="#browser.maxSession" /></td>
							<td><s:property value="#browser.maxInstance" /></td>
							<td><s:property value="#browser.configer" /></td>
							<td><s:property value="#browser.createDate" /></td>
							<!-- glyphicon glyphicon-stop -->
							<td><s:a class="status" href="javascript:void(0)" id="status_%{#browser.id}"><em class="glyphicon glyphicon-play">运行中...</em></s:a></td>
							<td><s:a class="glyphicon glyphicon-remove"
									href="javascript:void(0)" id="%{#browser.id}"
									onclick="deleteConfigBrowser(this)">
									<em class="glyphicon glyphicon-remove"></em>
								</s:a></td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</div>
	</div>
	</div>
</body>
</html>